package dashboard

import 

type LinkIcon string

const (
	IconExternal  LinkIcon = "external"
	IconDashboard LinkIcon = "dashboard"
	IconQuestion  LinkIcon = "question"
	IconInfo      LinkIcon = "info"
	IconBolt      LinkIcon = "bolt"
	IconDoc       LinkIcon = "doc"
	IconCloud     LinkIcon = "cloud"
)

// ExternalLink describes dashboard-level external link.
// See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/manage-dashboard-links/#add-a-url-link-to-a-dashboard
type ExternalLink struct {
	Title                 string
	Description           string
	URL                   string
	Icon                  LinkIcon
	IncludeTimeRange      bool
	IncludeVariableValues bool
	OpenInNewTab          bool
}

func ( ExternalLink) () sdk.Link {
	 := false
	 := string(IconExternal)
	if .Icon != "" {
		 = string(.Icon)
	}

	return sdk.Link{
		Title:       .Title,
		Tooltip:     &.Description,
		URL:         &.URL,
		AsDropdown:  &,
		Icon:        &,
		IncludeVars: .IncludeVariableValues,
		KeepTime:    &.IncludeTimeRange,
		Tags:        make([]string, 0),
		TargetBlank: &.OpenInNewTab,
		Type:        "link",
	}
}

// DashboardLink describes dashboard-level links to other dashboards.
// See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/manage-dashboard-links/#dashboard-links
type DashboardLink struct { //nolint:revive
	Title string
	Tags  []string

	AsDropdown            bool
	IncludeTimeRange      bool
	IncludeVariableValues bool
	OpenInNewTab          bool
}

func ( DashboardLink) () sdk.Link {
	return sdk.Link{
		Title:       .Title,
		Tags:        .Tags,
		AsDropdown:  &.AsDropdown,
		IncludeVars: .IncludeVariableValues,
		KeepTime:    &.IncludeTimeRange,
		TargetBlank: &.OpenInNewTab,
		Type:        "dashboards",
	}
}